package com.example.demo.service;

import com.example.demo.dao.BookDao;
import com.example.demo.dao.BookMapper;
import com.example.demo.model.BookInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class BookService {
    @Autowired
    private BookMapper bookMapper;
    public List<BookInfo> getlist() {
        //获取数据
       // BookDao bookDao = new BookDao();
        List<BookInfo> list = bookMapper.selectall();
        //设置借阅状态
        for (BookInfo book : list) {
            if (book.getStatus() == "1") {
                book.setStatus("可借阅");
            } else {
                book.setStatus("不可借阅");
            }
        }
        return list;
    }
    public Integer addBook(BookInfo bookInfo){
        return bookMapper.userAddBook(bookInfo);
    }
}


